import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


const state = {
    // 初始化A和B组件的数据，等待获取
    data1: {},
    data2: {}
}


const mutations = {
    getdata1(state, payload) {
        // 将A组件的数据存放于state
        // state.data1 = payload.AMsg
        console.log("~~~~~~getdata1~~~~~"+(JSON.stringify(payload)));
        state.data1 = payload ;
    },
    getdate2(state, payload) {
        // 将B组件的数据存放于state
        // state.data2 = payload.BMsg
        state.data2 = payload;
        console.log("~~~~~~getdata2~~~~~"+(JSON.stringify(payload)));
    }
}


const vuex = new Vuex.Store({
    state ,
    mutations
})


export default vuex 




